feat: add achievements display menu and integrate into menus (#307)#309
feat: add achievements display menu and integrate into menus (#307)#309Keerthi421 wants to merge 1 commit intojvondermarck:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| allAchievements.add(new KillCountAchievement("ach_kill_10_name", "ach_kill_10_desc", 10, 50)); | ||
| allAchievements.add(new KillCountAchievement("ach_kill_20_name", "ach_kill_20_desc", 20, 100)); | ||
| allAchievements.add(new KillCountAchievement("ach_kill_50_name", "ach_kill_50_desc", 50, 250)); | ||
| allAchievements.add(new KillCountAchievement("ach_kill_100_name", "ach_kill_100_desc", 100, 500)); |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| allAchievements.add(new KillCountAchievement("ach_kill_100_name", "ach_kill_100_desc", 100, 500)); | |
| allAchievements.add( | |
| new KillCountAchievement("ach_kill_100_name", "ach_kill_100_desc", 100, 500)); |
| private boolean completed = false; | ||
|
|
||
| public KillCountAchievement(int targetKills, int rewardCoins) { | ||
| public KillCountAchievement(String nameKey, String descriptionKey, int targetKills, int rewardCoins) { |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| public KillCountAchievement(String nameKey, String descriptionKey, int targetKills, int rewardCoins) { | |
| public KillCountAchievement( | |
| String nameKey, String descriptionKey, int targetKills, int rewardCoins) { |
|
|
||
| public boolean isCompleted() { | ||
| return completed; | ||
| return com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance().getTranslation(descriptionKey) |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| return com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance().getTranslation(descriptionKey) | |
| return com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance() | |
| .getTranslation(descriptionKey) |
|
|
||
| public void onComplete() { | ||
| FXGL.getNotificationService().pushNotification("Achievement unlocked: " + getDescription()); | ||
| String achievementName = com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance().getTranslation(nameKey); |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| String achievementName = com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance().getTranslation(nameKey); | |
| String achievementName = | |
| com.dinosaur.dinosaurexploder.utils.LanguageManager.getInstance().getTranslation(nameKey); |
| import com.dinosaur.dinosaurexploder.achievements.Achievement; | ||
| import com.dinosaur.dinosaurexploder.achievements.AchievementManager; | ||
| import com.dinosaur.dinosaurexploder.achievements.KillCountAchievement; | ||
| import com.dinosaur.dinosaurexploder.constants.GameConstants; |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| import com.dinosaur.dinosaurexploder.constants.GameConstants; |
| private VBox createAchievementsList() { | ||
| VBox list = new VBox(15); | ||
| list.setPadding(new Insets(10)); | ||
| list.setAlignment(Pos.TOP_CENTER); | ||
| list.setStyle("-fx-background-color: transparent;"); | ||
|
|
||
| List<Achievement> achievements = achievementManager.getAllAchievements(); | ||
| for (Achievement achievement : achievements) { | ||
| list.getChildren().add(createAchievementBox(achievement)); | ||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| private VBox createAchievementsList() { | |
| VBox list = new VBox(15); | |
| list.setPadding(new Insets(10)); | |
| list.setAlignment(Pos.TOP_CENTER); | |
| list.setStyle("-fx-background-color: transparent;"); | |
| List<Achievement> achievements = achievementManager.getAllAchievements(); | |
| for (Achievement achievement : achievements) { | |
| list.getChildren().add(createAchievementBox(achievement)); | |
| } | |
| return list; | |
| } |
| list.getChildren().add(createAchievementBox(achievement)); | ||
| } | ||
|
|
||
| return list; |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| return list; | |
| private VBox createAchievementBox(Achievement achievement) { | |
| String name = languageManager.getTranslation(achievement.getNameKey()); | |
| String description = ""; | |
| if (achievement instanceof KillCountAchievement) { | |
| description = ((KillCountAchievement) achievement).getDescription(); | |
| } else { | |
| description = languageManager.getTranslation(achievement.getDescriptionKey()); |
| private VBox createAchievementBox(Achievement achievement) { | ||
| String name = languageManager.getTranslation(achievement.getNameKey()); | ||
| String description = ""; | ||
| if (achievement instanceof KillCountAchievement) { | ||
| description = ((KillCountAchievement) achievement).getDescription(); | ||
| } else { | ||
| description = languageManager.getTranslation(achievement.getDescriptionKey()); | ||
| } | ||
|
|
||
| Label nameLabel = new Label(name); | ||
| nameLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 14px; -fx-text-fill: #00FF00; -fx-font-weight: bold;"); | ||
|
|
||
| Text descText = getUIFactoryService().newText(description, Color.WHITE, 12); | ||
| descText.setWrappingWidth(400); | ||
|
|
||
| HBox statusBox = new HBox(10); | ||
| statusBox.setAlignment(Pos.CENTER_LEFT); | ||
|
|
||
| boolean isCompleted = achievement.isCompleted(); | ||
| Label statusLabel = new Label(isCompleted ? languageManager.getTranslation("unlocked").toUpperCase() : languageManager.getTranslation("locked").toUpperCase()); | ||
| statusLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: " + (isCompleted ? "#00FF00" : "#FF6666") + ";"); | ||
|
|
||
| Label rewardLabel = new Label(languageManager.getTranslation("reward") + ": " + achievement.getRewardCoins() + " " + languageManager.getTranslation("coin")); | ||
| rewardLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: #FFFF00;"); | ||
|
|
||
| VBox box = new VBox(8, nameLabel, descText, new HBox(20, statusLabel, rewardLabel)); | ||
| box.setPadding(new Insets(15)); | ||
| box.setStyle( | ||
| "-fx-background-color: rgba(0, 0, 0, 0.6);" | ||
| + "-fx-background-radius: 8;" | ||
| + "-fx-border-color: " + (isCompleted ? "rgba(0, 255, 0, 0.5)" : "rgba(255, 255, 255, 0.2)") + ";" | ||
| + "-fx-border-width: 1;" | ||
| + "-fx-border-radius: 8;"); | ||
|
|
||
| return box; | ||
| } |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| private VBox createAchievementBox(Achievement achievement) { | |
| String name = languageManager.getTranslation(achievement.getNameKey()); | |
| String description = ""; | |
| if (achievement instanceof KillCountAchievement) { | |
| description = ((KillCountAchievement) achievement).getDescription(); | |
| } else { | |
| description = languageManager.getTranslation(achievement.getDescriptionKey()); | |
| } | |
| Label nameLabel = new Label(name); | |
| nameLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 14px; -fx-text-fill: #00FF00; -fx-font-weight: bold;"); | |
| Text descText = getUIFactoryService().newText(description, Color.WHITE, 12); | |
| descText.setWrappingWidth(400); | |
| HBox statusBox = new HBox(10); | |
| statusBox.setAlignment(Pos.CENTER_LEFT); | |
| boolean isCompleted = achievement.isCompleted(); | |
| Label statusLabel = new Label(isCompleted ? languageManager.getTranslation("unlocked").toUpperCase() : languageManager.getTranslation("locked").toUpperCase()); | |
| statusLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: " + (isCompleted ? "#00FF00" : "#FF6666") + ";"); | |
| Label rewardLabel = new Label(languageManager.getTranslation("reward") + ": " + achievement.getRewardCoins() + " " + languageManager.getTranslation("coin")); | |
| rewardLabel.setStyle("-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: #FFFF00;"); | |
| VBox box = new VBox(8, nameLabel, descText, new HBox(20, statusLabel, rewardLabel)); | |
| box.setPadding(new Insets(15)); | |
| box.setStyle( | |
| "-fx-background-color: rgba(0, 0, 0, 0.6);" | |
| + "-fx-background-radius: 8;" | |
| + "-fx-border-color: " + (isCompleted ? "rgba(0, 255, 0, 0.5)" : "rgba(255, 255, 255, 0.2)") + ";" | |
| + "-fx-border-width: 1;" | |
| + "-fx-border-radius: 8;"); | |
| return box; | |
| } | |
| Label nameLabel = new Label(name); | |
| nameLabel.setStyle( | |
| "-fx-font-family: 'Public Pixel'; -fx-font-size: 14px; -fx-text-fill: #00FF00; -fx-font-weight: bold;"); | |
| Text descText = getUIFactoryService().newText(description, Color.WHITE, 12); | |
| descText.setWrappingWidth(400); | |
| HBox statusBox = new HBox(10); | |
| statusBox.setAlignment(Pos.CENTER_LEFT); | |
| boolean isCompleted = achievement.isCompleted(); | |
| Label statusLabel = | |
| new Label( | |
| isCompleted | |
| ? languageManager.getTranslation("unlocked").toUpperCase() | |
| : languageManager.getTranslation("locked").toUpperCase()); | |
| statusLabel.setStyle( | |
| "-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: " | |
| + (isCompleted ? "#00FF00" : "#FF6666") | |
| + ";"); | |
| Label rewardLabel = | |
| new Label( | |
| languageManager.getTranslation("reward") | |
| + ": " | |
| + achievement.getRewardCoins() | |
| + " " | |
| + languageManager.getTranslation("coin")); | |
| rewardLabel.setStyle( | |
| "-fx-font-family: 'Public Pixel'; -fx-font-size: 10px; -fx-text-fill: #FFFF00;"); | |
| VBox box = new VBox(8, nameLabel, descText, new HBox(20, statusLabel, rewardLabel)); | |
| box.setPadding(new Insets(15)); | |
| box.setStyle( | |
| "-fx-background-color: rgba(0, 0, 0, 0.6);" | |
| + "-fx-background-radius: 8;" | |
| + "-fx-border-color: " | |
| + (isCompleted ? "rgba(0, 255, 0, 0.5)" : "rgba(255, 255, 255, 0.2)") | |
| + ";" | |
| + "-fx-border-width: 1;" | |
| + "-fx-border-radius: 8;"); | |
| return box; | |
| } |
|
|
||
| achievementsButton.setMinSize(140, 60); | ||
| achievementsButton.setTranslateY(470); | ||
| achievementsButton.setOnAction(event -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| achievementsButton.setOnAction(event -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); | |
| achievementsButton.setOnAction( | |
| event -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); |
|
|
||
| LanguageManager languageManager = LanguageManager.getInstance(); | ||
| PauseButton btnBack = new PauseButton(languageManager.getTranslation("back"), this::fireResume); | ||
| PauseButton btnAchievements = new PauseButton(languageManager.getTranslation("achievements"), () -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); |
There was a problem hiding this comment.
[💄Spotless - Format] reported by reviewdog 🐶
| PauseButton btnAchievements = new PauseButton(languageManager.getTranslation("achievements"), () -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); | |
| PauseButton btnAchievements = | |
| new PauseButton( | |
| languageManager.getTranslation("achievements"), | |
| () -> FXGL.getSceneService().pushSubScene(new AchievementsMenu())); |
🎨 Code Formatting Issues5 Java file(s) need formatting. 💡 Quick fixClick the suggestions below:
Or run locally: mvn spotless:apply
git add -A && git commit -m "style: apply Spotless" && git push📚 More optionsAuto-format in your IDE:
Style guide: Google Java Style Guide 🤖 The DinoBot Team 🦖 |
|
❌ Build FailedThanks for your contribution to this open-source project! ❤️ Unfortunately the build for this pull request has failed:
Tip Please check the logs and fix any issues before re-running the workflow. Good luck with your debugging! 🐛 (or should I say dino-bugging? 🦖) The DinoBot Team 🦖 |
jvondermarck
left a comment
There was a problem hiding this comment.
Please verify these elements:
- Spotless issues, just run the command you see above
- Sonar issues: https://sonarcloud.io/project/security_hotspots?id=jvondermarck_dinosaur-exploder&pullRequest=309&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true


✅ PR Checklist
[Type]: clear description of changetype: Feature, Fix, Refactor, Docs, Test, Chore📝 What does this PR do?
This PR implements a centralized Achievements system with full UI integration, allowing players to track milestones and rewards from both the main menu and during gameplay.
Key changes:
-> UI Implementation
Created AchievementsMenu.java as a scrollable SubScene based on FXGLMenu
Dynamically displays all achievements with status and rewards
-> System Integration
Added navigation entry points .
-> Manager Enhancement
🔗 Related Issue